package com.guomao.demod;

public class RunnableDemo {

    public static void main(String[] args) {

        MyRunImpl run = new MyRunImpl();

        Thread t1 = new Thread(run, "thread-1");
        Thread t2 = new Thread(run, "thread-2");

//        守护线程会在主线程结束之后立马停止执行
        t1.setDaemon(true);
        t2.setDaemon(true);

        t1.start();
        t2.start();

        for (int i = 0; i < 20; i++) {
            System.out.println(Thread.currentThread().getName() + ":" + i);
        }

//        设置线程优先级
//        t1.setPriority(Thread.MAX_PRIORITY);
//        t2.setPriority(Thread.MIN_PRIORITY);

//        System.out.println(t1.getPriority());
//        System.out.println(t2.getPriority());
//
//        t1.start();
//        t2.start();
//        t1.setPriority(100);
//        t1.start();

//        try {
//            t1.join();//等待调用join方法的线程执行结束
//        } catch (InterruptedException e) {
//            throw new RuntimeException(e);
//        }
//        t2.start();


    }
}
